package legumes.client.services.callbacks;

import legumes.client.services.LegumesServicesHelper;
import legumes.client.services.util.rpc.SequencableRPCCall;
import legumes.shared.domain.Order;

public class SaveOrderCallback extends SequencableRPCCall<Order> {
	private long sellSessionId;
	private Order order;

	private boolean merge;
	private Order savedOrder;

	public SaveOrderCallback(long sellSessionId_, Order order_, boolean merge_) {
		sellSessionId = sellSessionId_;
		order = order_;
		merge = merge_;
	}

	public void setMerge(boolean merge_) {
		merge = merge_;
	}

	@Override
	protected void doCall() {
		LegumesServicesHelper.LEGUMES_SERVICES.save(sellSessionId, order,
				merge, this);
	}

	@Override
	public void onSuccess(Order result_) {
		savedOrder = result_;
		callNext();
	}

	public Order getSavedOrder() {
		return savedOrder;
	}

}
